<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class CommentController extends Controller
{
    //
    public function index(Request $request)
    {
    	$where = [];
    	$db = DB::table("comments");
    	if($request->has("userid")){
    		$name = $request->input("userid");
    		//添加where模糊匹配条件
    		$db->where("userid","like","%{$name}%");
    		$where['userid'] = $name;
    	}
    	
    	$list = $db->paginate(3);
    	// dd($list);
    	return view("admin.comment.user",["list"=>$list,"where"=>$where]);
    }
    public function destroy($id)
    {
    	DB::table("comments")->where("id",$id)->delete();
    	return redirect('admin/comment');
    }

}
